import { Injectable } from '@angular/core';

import { DomBase } from '../../dynamic/dom/dom-base';
import { DomDropdown } from '../../dynamic/dom/dom-dropdown';
import { DomTextbox } from '../../dynamic/dom/dom-textbox';

@Injectable()
export class QuestionDataService {

    // TODO: get from a remote source of question metadata
    // TODO: make asynchronous
    getDomBases() {

        let dombases: DomBase<any>[] = [

            new DomDropdown({
                key: 'brave',
                label: 'Bravery Rating',
                options: [
                    { key: 'solid', value: 'Solid' },
                    { key: 'great', value: 'Great' },
                    { key: 'good', value: 'Good' },
                    { key: 'unproven', value: 'Unproven' }
                ],
                order: 3
            }),

            new DomTextbox({
                key: 'firstName',
                label: 'First name',
                value: 'Bombasto',
                required: true,
                order: 1
            }),

            new DomTextbox({
                key: 'emailAddress',
                label: 'Email',
                type: 'email',
                order: 2
            }),

            new DomTextbox({
                key: 'sex',
                label: 'sex',
                controlType: 'radiogroup',
                type: 'radio',
                value: 2,
                order: 4,
                radios: [{
                    text: "男",
                    val: 1
                }, {
                    text: "女",
                    val: 2
                }]
            })
        ];

        return dombases.sort((a, b) => a.order - b.order);
    }
}
